#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int main()
{
	int i = 0;
	string op;
	string num1;
	string num2;
	string last;
	cin >> i;
	while (i--) {
		cin >> op;
		string ans;
		int n1, n2;
		int ret = 0;
		if (op == "a" || op == "b" || op == "c") {
			cin >> num1 >> num2;
			n1 = stoi(num1);
			n2 = stoi(num2);
			ans += num1;
			last = op;
			if (op == "a") {
				ans += '+';
				ret = n1 + n2;
			}
			else if (op == "b") {
				ans += '-';
				ret = n1 - n2;
			}
			else {
				ans += '*';
				ret = n1 * n2;
			}
		}
		else {
			num1 = op;
			cin >> num2;
			n1 = stoi(num1);
			n2 = stoi(num2);
			ans += num1;
			if (last == "a") {
				ans += '+';
				ret = n1 + n2;
			}
			else if (last == "b") {
				ans += '-';
				ret = n1 - n2;
			}
			else {
				ans += '*';
				ret = n1 * n2;
			}
		}
		ans = ans + num2 + "=" + to_string(ret);
		cout << ans << endl;
		cout << ans.size() << endl;
	}
	return 0;
}

int main8()
{
	int arr[26]={1,2,3 ,1,2,3,1,2,3, 1,2,3, 1,2,3, 1,2,3,4, 1,2,3, 1,2,3,4};
	int count=0;
	string s;
	getline(cin,s);
	for(int i=0;i<s.size();i++){
		if(s[i]==' ')
		count++;
		else
		count+=arr[s[i]-97];
	}
	cout<<count<<endl;
	return 0;
}

int main7()
{
	string s;
	cin>>s;
	int left=0;
	int right=s.size()-1;
	int flag=1;
	while(left<right){
		if(s[left]==s[right]){
			left++;
			right--;
		}else{
			flag=0;
			cout<<"no"<<endl;
			break;
		}
	}
	if(flag==1){
		cout<<"yes"<<endl;
	}
	
	return 0;
}

int main6()
{
	string str;
	while(cin>>str){
		int left=0;
		int right=str.size()-1;
		while(left<right){
			char tmp=str[left];
			str[left]=str[right];
			str[right]=tmp;
			left++;
			right--;
		}
		cout<<str<<endl;
	}
	
	
	return 0;
}

int main5()
{
	string str;
	int arr[300], pos = 0;
	getline(cin, str);
	int count = 0;
	for (int i = 0; i < str.size(); i++) {
		if (str[i] != ' ') {
			count++;
		}
		else {
			arr[pos] = count;
			count = 0;
			pos++;
		}
		if (i == str.size()-1) {
			arr[pos] = count;
			count = 0;
			pos++;
		}
	}
	for (int i = 0; i < pos; i++) {
		if (i == 0)
			cout << arr[i];
		else
			cout << ',' << arr[i];
	}
	return 0;
}

int main4()
{
	int q=0;
	cin>>q;
	string s,s1;
	cin>>s;
	int op;
	int a2,b2,pos3,ret4;
	for(int i=0;i<q;i++){
		cin>>op;
		switch(op){
			case 1:
				cin>>s1;
				s+=s1;
				cout<<s<<endl;
				break;
			case 2:
				cin>>a2>>b2;
				s=s.substr(a2,b2);
				cout<<s<<endl;
				break;
			case 3:
				cin>>pos3>>s1;
				s.insert(pos3,s1);
				cout<<s<<endl;
				break;
			case 4:
				cin>>s1;
				ret4=s.find(s1);
				cout<<ret4<<endl;
				break;
		}
	} 
	
	
	return 0;
}

int main3()
{
	string pw;
	getline(cin,pw);
	for(int i=0;i<pw.size();i++){
		if(pw[i]==65||pw[i]==97){
			pw[i]+=25;
		}else if(isalpha(pw[i])){
			pw[i]--;
		}
	}
	cout<<pw;
	return 0;
}

int main2()
{
	int n=0;
	cin>>n;
	string s1,s2;
	for(int i=0;i<n;i++){
		cin>>s1;
		cin>>s2;
		if(s1==s2)
		cout<<"Tie"<<endl;
		else if(s1=="Rock"&&s2=="Scissors")
		cout<<"Player1"<<endl;
		else if(s1=="Scissors"&&s2=="Paper")
		cout<<"Player1"<<endl;
		else if(s1=="Paper"&&s2=="Rock") 
		cout<<"Player1"<<endl;
		else
		cout<<"Player2"<<endl;
	}
	
	
	return 0;
}

int main1()
{
	string title;
	getline(cin,title);
	int n=0;
	for(int i=0;i<title.size();i++){
		if(isspace(title[i]))
		continue;
		else
		n++;
	}
	
	cout<<n<<endl;

	return 0;
}
